#!/usr/bin/python
#-*-coding: utf-8 -*-

__all__ = [u'tk_gui_launcher']

def tk_gui_launcher (name):
  u"""
  Returns Tk GUI launcher python code
  """
  variables = dict(name=name)
  runpy = """
import sys, os

try: 
  PYLOTPATH = os.environ['PYLOTPATH']
except KeyError : 
  print "please define PYLOTPATH variable :"
  print "\texport PYLOTPATH=/full/path/to/pylot"
  print "\texample: export PYLOTPATH=/home/user/pylot/Resources"
  sys.exit()
else :
  print 'pyLot version used : %s' %PYLOTPATH
  PYTHONPATH = os.sep.join((PYLOTPATH, 'python', 'lib'))
  sys.path.append(PYTHONPATH)

paths = os.environ['PYLOTPATH'].split(os.sep)
os.environ['PYLOTPATH'] = os.sep.join(paths[:-2])

from pylotrun import *
from Tkinter import *

root = Tk();
""" + "RunpyLot(root,'%(name)s')" % (variables)

  return runpy
